<?php


namespace app\models\user;


use app\common\OrderStatus;
use app\services\user\UserRecordService;
use think\facade\Db;
use think\Model;

class ProgramInfoModel extends Model
{
    protected $name = 'program_info';

    protected $autoWriteTimestamp = true;

    protected static $exceptField = ['create_time', 'update_time'];

    protected static $fieldArr = [
        'program_sn' => '项目编号',
        'program_name' => '项目名称',
        'user_name' => '客户姓名',
        'process' => '项目进度',
    ];


//    public static function onAfterUpdate($model)
//    {
//        $table = $model->getTable();
//        $columns = Db::query("SHOW COLUMNS FROM `{$table}`");
//        foreach ($columns as $column) {
//            $columnName = $column['Field'];
//            $oldValue = $model->getOrigin($columnName);
//            $newValue = $model->getData($columnName);
//            if (!in_array($columnName, self::$exceptField) && $oldValue != $newValue) {
//                $changeArr = [
//                    $columnName => [
//                        'old' => $oldValue,
//                        'new' => $newValue,
//                    ],
//                ];
//                FieldChangeModel::create([
//                    'field_name' => $columnName,
//                    'old_value' => $oldValue,
//                    'new_value' => $newValue,
//                    'change_time' => time(),
//                ]);
//            }
//        }
//    }
}